<template>
  <!--推荐商家-->
  <div class="nearby" >
    <van-tabs color="green">
      <van-tab title="推荐商家">

        <div class="content" >
          <div class="content-header" v-for="item in storeList" @click="toShopView(item.storeId)">
            <div class="logo">
              <div v-if="!item.imgUrl">
              <img :src="getHeadImageUrl(item.storeIcon)" alt=""/></div>
              <!-- <div >
                <img :src="item.storeIcon">
              </div> -->
            </div>
            <div class="title">
              <span class="content-content_title">{{ item.storeName }}</span>
            </div>
            <div class="dec">
              <span class="grade">❤4.5</span>
              <span class="dis">755m</span>
            </div>
            <div class="desc">
              <span class="greenborder">便宜又好喝</span>
              <!-- <span class="blueborder">{{item.storeAdd}}</span> -->
            </div>
          </div>
        </div>

      </van-tab>
    </van-tabs>
  </div>
</template>

<script setup>
import { Notify, Toast, Dialog } from 'vant';
import { ref, reactive, onBeforeMount } from 'vue';
import { useRouter } from 'vue-router';
import { getHeadImageUrl } from '@/utils/api.js'
import http from '@/utils/request.js'
const router = useRouter();
const storeList = reactive([])
//显示商家列表（张仕琪）
const getStoreList =function () {
  http.get(
    '/store'
  ).then((res)=>{
    console.log('获取到的商家列表：',res.data);
    res.data.data.stores.forEach(store => {
      storeList.push(store);
    });
  })
}
//进入商家
const toShopView = function (storeId) {
  //路由地址： /shop/1
  router.push({ name: 'shop', params: { storeid: storeId } })
}

//获取商家列表方法
getStoreList();
</script>

<style scoped lang="scss">
.content{
    // height: 150px;
    overflow-y: scroll;
    &-header{
        box-sizing: border-box;
        width: 100%;
        height: 100px;
        padding: 15px;
        position: relative;
        .logo{
            width: 82px;
            height: 61px;
            img{
                width: 82px;
                height: 61px;
            }
        }
        .image{
            width:35px;
            height: 20px;
            position: absolute;
            top: 15px;
            left: 102px;
            img{
                width: 30px;
                height: 20px;
            }
        }
        .title {
            width: 200px;
            font-size: 16px;
            color: #000;
            position: absolute;
            top:15px;
            left: 115px;
            font-size: 20px;
        }
        .dec{
            width: 260px;
            height: 16px;
            position: absolute;
            top: 20px;
            left: 200px;
            .grade{
                margin-left: 50px ;
                font-size: 14px;
                color: #FF8000;
                font-weight: 600;
                position: absolute;
                display: inline-block;
            }
            .dis{
                margin-left:120px ;
                font-size: 12px;
                color: #333;
                font-weight: 600;
                position: absolute;
                display: inline-block;
            }
        }
        .desc{
            width:200px;
            height: 20px;
            position: absolute;
            top: 55px;
            left: 85px;
            .greenborder{
                margin-left: 30px;
                border: 1px solid rgb(25, 93, 18);
                color: rgb(25, 93, 18);
                font-size: 16px;
            }
            .blueborder{
                margin-left: 10px;
                border: 1px solid rgb(39, 37, 175);
                color: rgb(39, 37, 175);
                font-size: 16px;
            }
        }
    }
}
</style>

